#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
using namespace std;


int main()
{
    int n;
    cin >> n;
    while (n--)
    {
        int tmp;
        cin >> tmp;
        int a = 1;
        --tmp;
        int ret = 1;
        while (tmp)
        {
            if (tmp % (2 * a) == 0)
            {
                //cout<<"tmp:"<<tmp<<"a:"<<a<<endl;
                a *= 2;
                tmp -= a;
            }
            else tmp -= a;
            ++ret;
        }
        cout << ret << endl;
    }
    return 0;
}